package com.wyc.fast.controller;


import com.wyc.commonutils.R;
import com.wyc.fast.util.HandleUpload;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/edufast/filefast")
public class FastController {
    @Autowired
    HandleUpload handleUpload;

    //上传头像的方法
    @PostMapping
    public R uploadOssFile(MultipartFile file) {
        //获取上传文件  MultipartFile
        //返回上传到oss的路径
        String url = null;
        try {
            url = handleUpload.uploadFile(file);
        } catch (IOException e) {
            e.printStackTrace();
            url = "";
        }
        return R.ok().data("url",url);
    }

}
